package com.ssm.car.dao.mapper.parking;

import com.github.pagehelper.PageInfo;
import com.ssm.car.dao.model.Parking;
import com.ssm.upms.dao.mapper.ssm.LzDao;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* 停车场管理 Dao
* @author GaoXiang
* @version 1.0
*/
@Repository
public class ParkingDao extends LzDao<Parking> {



    /**
    * 保存数据
    * @param parking 实体对象
    * @return 实体id
    * @throws Exception 数据保存异常
    */
    public Integer insert(Parking parking) throws Exception {
        return insert("ParkingMapper.insert",parking);
    }

    /**
    * 根据 id 修改
    * @param parking 带id的实体对象
    * @return 受影响的行数
    * @throws Exception 数据修改异常
    */
    public Integer updateById(Parking parking) throws Exception {
        return update("ParkingMapper.updateById",parking);
    }

    /**
    * 根据 id 删除
    * @param id 数据id
    * @return 受影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteById(String id) throws Exception {
        return delete("ParkingMapper.deleteById",id);
    }

    /**
    * 根据 id 查找
    * @param id 实体id
    * @return 实体
    */
    public Parking selectById(String id) {
        return selectOne("ParkingMapper.selectById",id);
    }

    /**
    * 根据 id 批量删除
    * @param ids 要删除的id
    * @return 影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteByIds(List<String> ids) throws Exception {
        return delete("ParkingMapper.deleteByIds",ids);
    }

    /**
    * 查询列表
    * @param map 参数
    * @return 列表
    */
    public PageInfo<Parking> list(Map map) {
        return list("ParkingMapper.list",map);
    }

    /**
    * 查询列表 带分页
    * @param map 参数
    * @param page 页码
    * @param size 每页大小
    * @return 列表
    */
    public PageInfo<Parking> list(Map map, int page, int size) {
        return list("ParkingMapper.list",map,new RowBounds(page,size));
    }

    /**
     * 选择停车场
     * @param map
     * @return 集合
     */
    public List<Parking> chooseParking(Map map){
        return arrayList("ParkingMapper.chooseParking",map);
    }

    /**
     * 停车场列表
     * @param map 参数
     * @return 集合
     */
    public  List<Parking> listAll(Map map){
        return  arrayList("ParkingMapper.listAll",map);
    }

    /**
     * 根据区域查询停车场
     * @param parking
     * @return
     */
    public List<Parking> selectByCity(Parking parking){

        return arrayList("ParkingMapper.selectByCity",parking);
    }


    public Long countParkTotal(Parking parking){

        return count("ParkingMapper.countParkTotal",parking);
    }

    public Long countPark(Parking parking){

        return count("ParkingMapper.countPark",parking);
    }
    public Long countAutoParkTotal(Parking parking){

        return count("ParkingMapper.countAutoParkTotal",parking);
    }
    public Long countAutoPark(Parking parking){

        return count("ParkingMapper.countAutoPark",parking);
    }

    public Long countOrdinaryParkTotal(Parking parking){
        return count("ParkingMapper.countOrdinaryParkTotal",parking);
    }
    public Long countOrdinaryPark(Parking parking){
        return count("ParkingMapper.countOrdinaryPark",parking);
    }


    public List<Parking> selectByParking(Parking parking){
        return arrayList("ParkingMapper.selectByParking",parking);
    }


}
